package com.sojson.config.exception.impl;

import com.sojson.config.exception.GlobalExceptionHandlerInterface;
import com.sojson.util.StringUtil;

/**
 * 异常统一处理实现类
 * 
 * @author liu
 * @date 2021-04-14
 */
public class GlobalExceptionHandlerTestImpl implements GlobalExceptionHandlerInterface {

    private static GlobalExceptionHandlerTestImpl globalExceptionHandlerTestImpl;

    private GlobalExceptionHandlerTestImpl() {}

    /**
     * 异常的统一处理
     * 
     * @param e
     * @return
     */
    @Override
    public Object defaultErrorHandler(Exception e) {
        e.printStackTrace();
        return e;
    }

    /**
     * 判断一个对象是否是空(空对象)
     * 
     * @param obj
     * @return
     */
    private static boolean isBlankObject(Object obj) {
        return StringUtil.isBlankObject(obj);
    }

    public static GlobalExceptionHandlerTestImpl getInstances() {
        if (isBlankObject(globalExceptionHandlerTestImpl)) {
            globalExceptionHandlerTestImpl = new GlobalExceptionHandlerTestImpl();
        }
        return globalExceptionHandlerTestImpl;
    }

}